#include <SimpleDef.h>
#include <FileSystem/Disk.h>
#include <Memory/Paging.h>
#include <Memory/Heap.h>
#include <ProcessThread/ProcessThread.h>
#include <Utility/CLib.h>
#include <FileSystem/FileAPI.h>
#include <Memory/Heap.h>
#include <Kernel/GlobalData.h>

LPVOID LoadProgram(LPCSTR lpszPath)
{
    LPThreadControlBlock lpCurrentThread = (LPVOID)((DWORD)&lpCurrentThread & 0xFFFFE000); /* 当前栈底保存线程 PCB */
    LPFileObject lpFileObj = SimpleCreateFile(lpszPath, 0);
    LPBYTE lpProgBits = HeapAllocate(g_lpKernelHeap, 0, PAGE_SIZE);
    LPVOID lpProgramBits = AllocatePageForUser(4, PTE_USER);
    LPVOID lpFileContent = AllocatePageForUser(4, PTE_USER);
    
    SimpleReadFile(lpFileObj, lpFileContent, lpFileObj->lpFCB->dwFileSize, NULL);
    return ResolveELF32(lpFileContent);
}